-
Notifications
You must be signed in to change notification settings - Fork 368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement AerDensityMatrix #1732
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To get consistent results of sample_memory()
, seed()
needs to be overwritten and self._aer_state
needs to be used for this method.
a71f17f adds these function into AerStatevector
.
|
||
self._result = None | ||
self._configs = configs | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def seed(self, value=None): | |
"""Set the seed for the quantum state RNG.""" | |
if value is None or isinstance(value, int): | |
self._aer_state.set_seed(value) | |
else: | |
raise AerError(f'This seed is not supported: type={value.__class__}, value={value}') | |
seed method is missing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had overlooked this. So Terra's QuantumState.seed is called and the effect of the call to seed() in test_aer_densitymatrix.py is inadequate. OK, I will fix this as you suggested.
aer_state = AerState(**self._aer_state.configuration()) | ||
aer_state.initialize(self._data, copy=False) | ||
samples = aer_state.sample_memory(qubits, shots) | ||
aer_state.close() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aer_state = AerState(**self._aer_state.configuration()) | |
aer_state.initialize(self._data, copy=False) | |
samples = aer_state.sample_memory(qubits, shots) | |
aer_state.close() | |
self._aer_state.close() | |
self._aer_state.renew() | |
self._aer_state.initialize(self._data, copy=False) | |
samples = self._aer_state.sample_memory(qubits, shots) | |
self._data = self._aer_state.move_to_ndarray() |
To keep a random generator in AerState
, sample_memory
needs the same AerState
instance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. I will correct it according to your suggestion and #1663.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now this looks good to me. Thank you for your contribution.
Summary
This is a PR to implement AerDensityMatrix, which is a fine-tuned version of #1676.
Details and comments
When this PR is approved, #1676 should be closed at the same time.